<?php
namespace app\view\controller;

use app\api\controller\BaseController;
use app\common\exception\SuccessException;
use app\facade\view\YuwenService;
use think\facade\Request;
use think\Db;

/**
 * 首页
 */
class Yuwen extends BaseController
{

    /**
     * 获取指定年级文字
     */
    public function wordsList()
    {
        $params = Request::param();
        $where = [
            'grade_id' =>  $params['grade'] ?? 1,
            'status' =>  1,
            'category_id' =>  $params['category'] ?? '',
        ];
        $fields = 'id, words, volume, lesson_name, attr';
        $res = YuwenService::getAll($where, $fields, ['order' => 'dec']);
        throw new SuccessException(['content' => $res, 'msg' => 'SUCCESS']);
    }
}
